import { CACHE_MANAGER, Inject, Injectable } from '@nestjs/common';
import { Cache } from 'cache-manager';
import * as Redis from "redis";

@Injectable()
export class RedisService {
    public store:Redis.RedisClient;
    constructor(
        @Inject(CACHE_MANAGER) private cacheManager:Cache
    ) {
        const store:any = this.cacheManager.store
        this.store = store.getClient()
    }

    rPop(queueName:string) :Promise<string>{
        return new Promise((resolve, reject) => {
            this.store.rpop(queueName, (error, data) => {
                resolve(data)
            })
        })
    }
}
